################################## 
############ Preamble ############ 
################################## 

# set language to English
Sys.setenv(LANG = "en")

# clean up
rm(list = ls())

# Set working directory: please set your own
#setwd("~/Dropbox/JOP third submission/JOP replication/")

# load necessary packages
library(tidyverse)
library(haven)

######################################### 
############ End of preamble ############ 
######################################### 

# Import the data
other_outcomes_data <- read.dta13("01_data/other_outcomes.dta")

# Make the plot
other_outcomes_plot <-  other_outcomes_data %>%
  # Filter out the model that was run just to create the dataset
  filter(Model > 0) %>%
  mutate(ci_lower_90 = coef - 1.645 * stderr) %>%
  mutate(ci_upper_90 = coef + 1.645 * stderr) %>%
  ggplot(aes(x = Outcome, y = coef)) +
  geom_hline(aes(yintercept = 0), linetype = 2, color = "red") + 
  coord_flip( ) + 
  geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75) ) + 
  geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75), size = 0.5) + 
  geom_linerange(aes(ymin = ci_lower_90, ymax = ci_upper_90), position = position_dodge(width = 0.75), size = 1) +
  geom_point(size = 1, position = position_dodge(width = 0.75) ) + 
  theme_minimal(base_size = 9) +
  theme_bw() +
  facet_wrap(~Model, nrow = 1, ncol = 3) +
  labs(y = "Effect of absence of private voting booth (percentage points)", x = "Outcome")
other_outcomes_plot

ggsave("04_plots/figured1.png", plot = other_outcomes_plot, width = 20, height = 15, units = "cm")